<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        #out{
            height: 500px;
            background-color: #dddddd;
            position: relative;
        }

        .rect{
            width: 100px;
            height: 100px;
            position: absolute;
        }
        #red{
            background-color: red;
            top: 0;
            left: 0;
        }
        #green{
            background-color: green;
            top: 0;
            right: 0;
        }
        #blue{
            background-color: blue;
            left: 0;
            bottom: 0;
        }
        #pink{
            background-color: pink;
            right: 0;
            bottom: 0;
        }
        #purple{
            background-color: purple;
            
            /*margin: auto;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;*/

            left: 50%;
            top: 50%;
            transform: translateX(-50%) translateY(-50%);

        }
    </style>
</head>
<body>
    <div id="out">
        <div class="rect" id="red"></div>
        <div class="rect" id="green"></div>
        <div class="rect" id="blue"></div>
        <div class="rect" id="pink"></div>
        <div class="rect" id="purple"></div>
    </div>
</body>
</html>